import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/components/layout'
import Index from '@/components/index'
// 系统设置模块
import SettingUserList from '@/view/system/userList'
import SettingRoleList from '@/view/system/roleList'
import SettingRequestPathList from '@/view/system/requestPathList'
import SettingPermissionList from '@/view/system/permissionList'
//
import CommodityList from '@/view/commodity/list'
import CommodityView from '@/view/commodity/view'
import CommodityDialog from '@/view/commodity/dialog'
// 面试测试用户模块
import TestUserList from '@/view/testUser/list'
import TestUserView from '@/view/testUser/view'
import TestUserDialog from '@/view/testUser/dialog'

// start 解决路由重复虽然对项目无影响，但是看到有红的不舒服！
const originalPush = Router.prototype.push
Router.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}
const originalReplace = Router.prototype.replace
Router.prototype.replace = function replace (location) {
  return originalReplace.call(this, location).catch(err => err)
}
// end
Vue.use(Router)
export default new Router({
  routes: [
    {
      path: '/',
      name: 'Layout',
      component: Layout,
      redirect: '/index',
      children: [{
        path: '/index',
        name: 'Index',
        component: Index,
        meta: {
          title: '首页'
        }
      },
      {
        path: '/setting/userList',
        name: 'SettingUserList',
        component: SettingUserList,
        meta: {
          title: '用户列表'
        }
      },
      {
        path: '/setting/roleList',
        name: 'SettingRoleList',
        component: SettingRoleList,
        meta: {
          title: '角色列表'
        }
      },
      {
        path: '/setting/permissionList',
        name: 'SettingPermissionList',
        component: SettingPermissionList,
        meta: {
          title: '权限列表'
        }
      },
      {
        path: '/setting/requestPathList',
        name: 'SettingRequestPathList',
        component: SettingRequestPathList,
        meta: {
          title: '资源列表'
        }
      },
      {
        path: '/commodity/list',
        name: 'CommodityList',
        component: CommodityList,
        meta: {
          title: '商品列表'
        }
      },
      {
        path: '/commodity/add',
        name: 'CommodityAdd',
        component: CommodityDialog,
        meta: {
          title: '添加商品'
        }
      },
      {
        path: '/commodity/edit',
        name: 'CommodityEdit',
        component: CommodityDialog,
        meta: {
          title: '编辑商品'
        }
      },
      {
        path: '/commodity/view',
        name: 'CommodityView',
        component: CommodityView,
        meta: {
          title: '商品详情'
        }
      },
      {
        path: '/testUser/list',
        name: 'TestUserList',
        component: TestUserList,
        meta: {
          title: '测试用户列表'
        }
      },
      {
        path: '/testUser/add',
        name: 'TestUserAdd',
        component: TestUserDialog,
        meta: {
          title: '添加测试用户'
        }
      },
      {
        path: '/testUser/edit',
        name: 'TestUserEdit',
        component: TestUserDialog,
        meta: {
          title: '编辑测试用户'
        }
      },
      {
        path: '/testUser/view',
        name: 'TestUserView',
        component: TestUserView,
        meta: {
          title: '测试用户详情'
        }
      }]
    }
  ]
})
